#include "exp_2.h"
int Queenes[N] = {0}, Counts = 0;
int Check(int line, int list) {
    for (int index = 0; index < line; index++) {
        int data = Queenes[index];
        if (list == data) {
            return 0;
        }
        if ((index + data) == (line + list)) {
            return 0;
        }
        if ((index - data) == (line - list)) {
            return 0;
        }
    }
    return 1;
}
void print() {
    for (int line = 0; line < 8; line++) {
        int list;
        for (list = 0; list < Queenes[line]; list++) {
            putchar(BLANK);
            putchar(' ');
        }
        putchar(QUEEN);
        putchar(' ');
        for (list = Queenes[line] + 1; list < 8; list++) {
            putchar(BLANK);
            putchar(' ');
        }
        printf("\n");
    }
    printf("================\n");
}

void eight_queen(int line) {
    for (int list = 0; list < 8; list++) {
        if (Check(line, list)) {
            Queenes[line] = list;
            if (line == 7) {
                Counts++;
                print();
                Queenes[line] = 0;
                return;
            }
            eight_queen(line + 1);
            Queenes[line] = 0;
        }
    }
}
void solve8Quees_exhaustion() {
    eight_queen(0);
    printf("摆放的方式有%d种", Counts);
}